-
Notifications
You must be signed in to change notification settings - Fork 27
Update plotSpectra environment to allow addFragments returned list #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I have however some questions.
General comment: I don't know your specific use case, but would it not be possible to add whatever information/annotation you have or calculate directly to the |
I believe we could if the number of annotations don't exceed |
A discussion with Laurent led to a potential different idea: the creation of a package specifically for plotting spectra. I understand my use cases might not fit in well within the |
@jorainer - we need to move on with this issue to be able to merge the new PSMatch functionality. Do we need another discussion. |
… plotting functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware of possible side effects of changing labels = character()
to labels = list()
. Did you try to rebuild the vignettes and reverse dependencies?
@@ -319,7 +345,7 @@ setMethod( | |||
xlim[1L] <- xlim[1L] - wdths | |||
xlim[2L] <- xlim[2L] + wdths | |||
plot.window(xlim = xlim, ylim = ylim, ...) | |||
} | |||
} else {labels <- NULL} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? Isn't the if (length(labels))
statement already enough?
Maybe, we should change the default to label = list()
instead of the current label = character()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we do need it. If labels is an empty list, when calling .plot_single_spectrum
, an error occurs: the subscript is out of bounds (labels[[i]]
of an empty list). If labels is NULL, this error does not occur
for (i in seq_len(nsp)) | ||
.plot_single_spectrum(x[i], xlab = xlab, ylab = ylab, type = type, | ||
xlim = xlim, ylim = ylim, main = main[i], | ||
col = col[[i]], labels = labels, | ||
col = col[[i]], labels = labels[[i]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the default for label
in .plot_single_spectrum
should be changed as well?
(and instead of testing label in each of the other function it should be done once in .plot_single_spectrum
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It had to come before because I needed to match the spectrum and the labels before .plot_single_spectrum
is called. The default labels
in .plot_single_spectrum
thus still reamains a character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK merging after Sebastian's comments have been addressed.
This might now however break code in other packages too - could you, for backward compatibility, maybe you could add a check to the functions
if (is.character(labels))
labels <- as.list(labels)
still, in the documentation etc I would not mention the support for character
, this is purely for existing code in other packages or our analysis workflows that would now break, because we're passing a character
.
I changed into this: if (is.character(labels))
labels <- list(labels) Since otherwise it would create a list of length equal to the number of peaks in the spectrum. |
There was also an error with the old par not being returned after plotting multiple plots. I made sure plotSpectra now returns it |
what puzzles me a bit is that the GHA are not running for this PR. Would be nice to actually see if all unit tests run smoothly |
I ran the tests |
I am trying to use the Vignettes also build locally. |
I have updated the action file - I think the checks should be run now for PRs. |
It was apparently a timeout issue. All reverse dependencies are ok.
|
@sgibb - I confirm that the package and all revdeps check correctly. |
This PR is linked to this PSMatch issue and the discussed topics in #346
The motivation for this PR:
addFragments
used to throw an error when multiple spectra where calledvariable_modifications
parameter necessitated a newaddFragments
function to distinguish annotationsThe solution:
addFragments
now returns a list of named elements (peptide sequence that includes modifications) containing acharacter()
vector with the annotations. Each element of the list has an attribute linking the annotations to the spectrum it belonged to. In Spectra, the changes are located at the level of the presence oflabels
. It is assumed that most often than not,addFragments
is called forlabels
. A quick check for variable modifications is also added (as plotSpectra doesn't support them yet). All three functions (plotSpectra
,plotSpectraMirror
andplotSpectraOverlay
now support the version ofaddFragments
in this PR).This PR can only be accepted if the corresponding PR in PSMatch is accepted !! Otherwise,
plotSpectra
won't work.